package com.whw.springboot.walk.controller;


import com.whw.springboot.walk.entity.Message;
import com.whw.springboot.walk.entity.UserInfo;
import com.whw.springboot.walk.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "用户信息模块")
@RestController
@RequestMapping("/api/userInfo")
public class UserInfoController {

    @Resource
    private UserInfoService userInfoService;

    @ApiOperation(value = "添加用户信息")
    @PostMapping(value = "/insert")
    public Message insertInfo(UserInfo userinfo){
        return userInfoService.AddUserInfo(userinfo);
    }

    @ApiOperation(value = "更新用户信息")
    @PutMapping(value="/update")
    public Message updateUserInfo(UserInfo userInfo){
        return userInfoService.updateUserInfoByPrimaryKeySelective(userInfo);
    }

    @ApiOperation(value = "根据生源地查询所有user_info中信息")
    @GetMapping(value = "/getByOldStatus")
    public Message<List<UserInfo>>  findUserInfoByOldStatues(String oldStatus){
        return userInfoService.selectUserInfoByOldStatues(oldStatus);
    }

    @ApiOperation(value = "删除用户信息")
    @DeleteMapping(value = "/delByUserId")
    public Message delUserInfoByUserId(String userId){
        return userInfoService.deleteUserInfo(userId);
    }


    @ApiOperation(value = "通过活动ID查询参加了该活动的用户信息")
    @GetMapping(value = "/findUserInfoByActId")
    public Message<List<UserInfo>> findUserInfoByActId(String actId){
        return userInfoService.findUserInfoByActId(actId);
    }

}
